<?php

/**
 * Contestant form base class.
 *
 * @method Contestant getObject() Returns the current form's model object
 *
 * @package    wills
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseContestantForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'application_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('application'), 'add_empty' => false)),
      'area_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('area'), 'add_empty' => false)),
      'name'           => new sfWidgetFormInputText(),
      'number'         => new sfWidgetFormInputText(),
      'address'        => new sfWidgetFormInputText(),
      'phone'          => new sfWidgetFormInputText(),
      'portrait'       => new sfWidgetFormInputText(),
      'image'          => new sfWidgetFormInputText(),
      'win'            => new sfWidgetFormInputCheckbox(),
      'lose'           => new sfWidgetFormInputCheckbox(),
      'hits'           => new sfWidgetFormInputText(),
      'note'           => new sfWidgetFormInputText(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'application_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('application'))),
      'area_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('area'))),
      'name'           => new sfValidatorString(array('max_length' => 255)),
      'number'         => new sfValidatorInteger(array('required' => false)),
      'address'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'phone'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'portrait'       => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'image'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'win'            => new sfValidatorBoolean(array('required' => false)),
      'lose'           => new sfValidatorBoolean(array('required' => false)),
      'hits'           => new sfValidatorInteger(array('required' => false)),
      'note'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Contestant', 'column' => array('application_id')))
    );

    $this->widgetSchema->setNameFormat('contestant[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contestant';
  }

}
